# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html


# useful for handling different item types with a single interface
from itemadapter import ItemAdapter

import json

class CarKoubeiPipeline:
    # def process_item(self, item, spider):
    #     #get方法是取 item 的属性，属性为空则默认为 --
    #     name = item.get('name', '-')
    #     grade = item.get('grade', '0')
    #     date = item.get('date', '--')
    #
    #     line = '{0},{1},{2}'.format(name,grade,date)
    #     #print(f'------{line}')
    #     # 写入文件
    #     with open("koubei.txt", 'a+', encoding='utf-8') as fp:
    #         fp.write(line + '\n')
    pass

